﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using System.Data.SqlClient;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data;
using System.Collections;

namespace CDTM.Modules.TraCuuDiem.Components
{
    public partial class HocSinh
    {
        public static List<HocSinh> SelectBy(string maSV, string hoTen, int heTaoTaoID)
        {
            List<HocSinh> list = HocSinh.SelectCollectionAll().Where(x => x.MaSV == maSV
               && (x.HoLot.Contains(hoTen) || x.Ten.StartsWith(hoTen))).OrderBy(x => x.Ten).ToList<HocSinh>();

            return list;

        }

        public static List<HocSinh> SelectBy(string maSV, string hoTen)
        {
            List<HocSinh> list = HocSinh.SelectCollectionAll().Where(x => x.MaSV == maSV
               && (x.HoLot.Contains(hoTen) || x.Ten.StartsWith(hoTen))).OrderBy(x => x.Ten).ToList<HocSinh>();

            return list;

        }

        public static List<HocSinh> SelectByMaSV(string maSV)
        {
            List<HocSinh> list = HocSinh.SelectCollectionAll().Where(x => x.MaSV == maSV).OrderBy(x => x.Ten).ToList<HocSinh>();

            return list;

        }

        public static List<HocSinh> SelectByHoTen(string hoTen)
        {
            List<HocSinh> list = HocSinh.SelectCollectionAll().Where(x => (x.HoLot.Contains(hoTen) || x.Ten.StartsWith(hoTen))).OrderBy(x => x.Ten).ToList<HocSinh>();

            return list;

        }

        public static List<HocSinh> Clean(List<HocSinh> list)
        {
            List<HocSinh> newList = new List<HocSinh>();

            var cleanList = from item in list where item.MaSV != "" select item;

            foreach (HocSinh obj in cleanList)
            {
                newList.Add(obj);
            }

            return newList;
        }

        //---------------------------------------------------------------------------------------------

        public static int DeleteAll()
        {
            return DeleteDynamic("1=1");
        }

    }
}
